package cn.cmdr.mapper;


import cn.cmdr.pojo.Commodity;
import cn.cmdr.pojo.Stock;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ComMapper extends BaseMapper<Commodity> {
    public  List<Commodity> getComPageList(Page page ,@Param("ew") Wrapper wrapper);
    //分类
    @Select("select * from cmdr_stock s,cmdr_commodity c WHERE s.commodity_id = c.id and s.commodity_id=#{commodityId}")
    public List<Stock> getStockByComId(Integer commodityId);
    //品牌
    @Select("select * from cmdr_commodity c,cmdr_brand b where c.brand_id = b.id and c.id=${id}")
    public List<Commodity> getComList(Integer id);
    //id查询商品
    @Select("select * from cmdr_commodity c,cmdr_brand b where c.brand_id = b.id and c.id=${id}")
    public Commodity getComById(Integer id);
    @Select("SELECT COUNT(*) FROM cmdr_commodity where delete_status = 0 and stock<low_stock or stock=low_stock")
    public int getKCount();

    Commodity getCom(Integer id);
}
